# 存储爬取的网页代码
import requests
# fn = 'file01.txt'
# fn = 'file01.html'
# fn = 'file01.doc'


def save_html(url, filename):

    try:
        html_file = requests.get(url)
        print(type(html_file))
    except Exception as err:
        print("网页下载失败： %s" % err)

    with open(filename, 'wb') as file_Obj:  # 以二进制存储
        for diskStorage in html_file.iter_content(10240):  # 循环取出内容
            size = file_Obj.write(diskStorage)  # 写入
            print(size)
            print("以 %s 存储网页html文件成功" % filename)
